package com.sxt.practiceapplication.utils.permission;

import android.content.Context;

public class GPermission {
    /**
     * 权限申请回调
     */
    private PermissionCallback callback;

    /**
     * 需要申请的权限
     */
    private String[] permissions;

    /**
     * 上下文
     */
    private final Context context;

    public GPermission(Context context) {
        this.context = context;
    }

    public static GPermission with(Context context) {
        return new GPermission(context);
    }

    public GPermission permission(String... permissions) {
        this.permissions = permissions;
        return this;
    }

    @SuppressWarnings("unused")
    public GPermission callback(PermissionCallback callback) {
        this.callback = callback;
        return this;
    }

    public void request() {
        if (permissions == null || permissions.length <= 0) {
            return;
        }
        PermissionActivity.request(context, permissions, callback);
    }

}